import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    torouter: '',
    token: '' || localStorage.getItem('token'),
    routerPath: '',
    screenWidth: true,
    name: '' || localStorage.getItem('name'),
    aboutPath: '',
    newsPath: '',
    homeInfo:{},
    userId:'' || localStorage.getItem('userId'),
    shopcartCount:null,
    move:false
  },
  getters: {
    torouter(state) {
      return state.torouter
    },
    homeInfo(state){
     return state.homeInfo
    },
    token(state) {

      return state.token
    },
    routerPath(state) {
      return state.routerPath
    },
    screenWidth(state) {
      return state.screenWidth
    },
    name(state) {
      return state.name
    },
    aboutPath(state) {
      return state.aboutPath
    },
    newsPath(state) {
      return state.newsPath
    },
    userId(state){
      return state.userId
    },
    shopcartCount(state){
      return state.shopcartCount
    },
    move(state){
      return state.move
    }

  },
  mutations: {
    setnewsPath(state, data) {
      state.newsPath = data

    },
    sethomeInfo(state,data){
     state.homeInfo =data
    },
    setaboutPath(state, data) {
      state.aboutPath = data
    },
    settoRouter(state, router) {
      state.torouter = router
    },
    settoekn(state, date) {
      state.token = date
      localStorage.setItem('token', date)
    },
    setrouterpath(state, path) {
      state.routerPath = path
    },
    setscreenWidth(state, boole) {
      state.screenWidth = boole
    },
    setname(state, data) {
      state.name = data
      localStorage.setItem('name', data)

    },
    setUserId(state,data){
        state.userId = data
        localStorage.setItem('userId', data)
    },
    setShopcartCount(state,data){
      state.shopcartCount = data
    },
    setMove(state,data){
      state.move = data
    }
  },
  actions: {

  }
})
